﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Drawing;
using PdfSharp;
using PdfSharp.Drawing;
using PdfSharp.Pdf;
using PdfSharp.Pdf.IO;
using PdfSharp.Pdf.Content;

/// <summary>
/// Summary description for EtiqaTAInsurancePDFOutput
/// </summary>
/// 
namespace CE.TravelInsurance
{
    public class EtiqaTAInsurancePDFOutput
    {
        private string _proposalId;
        public string ProposalId
        {
            get { return _proposalId; }
            set { _proposalId = value; }
        }

        private string _schedulewritingpagetitle;// "Etiqa - Schedule Writing";
        public string ScheduleWritingPageTitle
        {
            get { return _schedulewritingpagetitle; }
            set { _schedulewritingpagetitle = value; }
        }

        private string _certificatepagetitle;// "Etiqa - Certificate Of Insurance";
        public string CertificatePageTitle
        {
            get { return _certificatepagetitle; }
            set { _certificatepagetitle = value; }
        }

        private string _taxinvoicepagetitle;// "Etiqa - Tax";
        public string TaxInvoicePageTitle
        {
            get { return _taxinvoicepagetitle; }
            set { _taxinvoicepagetitle = value; }
        }

        private bool _ispromo;
        public bool isPromo
        {
            get { return _ispromo; }
            set { _ispromo = value; }
        }

        private string _newpremium;
        public string NewPremium
        {
            get { return _newpremium; }
            set { _newpremium = value; }
        }

        #region Customer Profile
        string _customerName;
        public string CustomerName
        {
            get { return _customerName; }
            set { _customerName = value; }
        }

        string _customerAddress1;
        public string CustomerAddress1
        {
            get { return _customerAddress1; }
            set { _customerAddress1 = value; }
        }

        string _customerAddress2;
        public string CustomerAddress2
        {
            get { return _customerAddress2; }
            set { _customerAddress2 = value; }
        }

        #endregion

        #region CI Variables
        string _agency;
        public string Agency
        {
            get { return _agency; }
            set { _agency = value; }
        }

        string _classOfPolicy;
        public string ClassOfPolicy
        {
            get { return _classOfPolicy; }
            set { _classOfPolicy = value; }
        }

        string _policyNumber;
        public string PolicyNumber
        {
            get { return _policyNumber; }
            set { _policyNumber = value; }
        }

        string _account;
        public string Account
        {
            get { return _account; }
            set { _account = value; }
        }

        string _issuedOn;
        public string IssuedOn
        {
            get { return _issuedOn; }
            set { _issuedOn = value; }
        }

        string _replacePolicyNumber;
        public string ReplacePolicyNumber
        {
            get { return _replacePolicyNumber; }
            set { _replacePolicyNumber = value; }
        }

        string _client;// "";
        public string Client
        {
            get { return _client; }
            set { _client = value; }
        }

        string _acceptanceDate;
        public string AcceptanceDate
        {
            get { return _acceptanceDate; }
            set { _acceptanceDate = value; }
        }

        string _startPeriod;
        public string PeriodInsuranceStart
        {
            get { return _startPeriod; }
            set { _startPeriod = value; }
        }

        string _endPeriod;
        public string PeriodInsuranceEnd
        {
            get { return _endPeriod; }
            set { _endPeriod = value; }
        }

        string _totalDueInvoice;
        public string TotalDueInvoice
        {
            get { return _totalDueInvoice; }
            set { _totalDueInvoice = value; }
        }

        string _occupation;
        public string Occupation
        {
            get { return _occupation; }
            set { _occupation = value; }
        }

        string _nric;
        public string NRICNo
        {
            get { return _nric; }
            set { _nric = value; }
        }

        string _dob;
        public string DOB
        {
            get { return _dob; }
            set { _dob = value; }
        }

        string _gender;
        public string Gender
        {
            get { return _gender; }
            set { _gender = value; }
        }

        string _planname;
        public string PlanName
        {
            get { return _planname; }
            set { _planname = value; }
        }

        string _typeofplan;
        public string TypeOfPlan
        {
            get { return _typeofplan; }
            set { _typeofplan = value; }
        }

        string _destination;
        public string Destination
        {
            get { return _destination; }
            set { _destination = value; }
        }

        string _noofdays;
        public string NoOfDays
        {
            get { return _noofdays; }
            set { _noofdays = value; }
        }

        //Spouse Variables
        string _spousestatus;
        public string SpouseStatus
        {
            get { return _spousestatus; }
            set { _spousestatus = value; }
        }
        string _spousename;
        public string SpouseName
        {
            get { return _spousename; }
            set { _spousename = value; }
        }

        string _spouseoccupation;
        public string SpouseOccupation
        {
            get { return _spouseoccupation; }
            set { _spouseoccupation = value; }
        }

        string _spousenric;
        public string SpouseNRICNo
        {
            get { return _spousenric; }
            set { _spousenric = value; }
        }

        string _spousedob;
        public string SpouseDOB
        {
            get { return _spousedob; }
            set { _spousedob = value; }
        }

        //Child 1
        string _childcount;
        public string ChildCount
        {
            get { return _childcount; }
            set { _childcount = value; }
        }

        string _childname1;
        public string ChildName1
        {
            get { return _childname1; }
            set { _childname1 = value; }
        }

        string _childnric1;
        public string ChildNRICNo1
        {
            get { return _childnric1; }
            set { _childnric1 = value; }
        }

        string _childdob1;
        public string ChildDOB1
        {
            get { return _childdob1; }
            set { _childdob1 = value; }
        }

        //Child 2
        string _childname2;
        public string ChildName2
        {
            get { return _childname2; }
            set { _childname2 = value; }
        }

        string _childnric2;
        public string ChildNRICNo2
        {
            get { return _childnric2; }
            set { _childnric2 = value; }
        }

        string _childdob2;
        public string ChildDOB2
        {
            get { return _childdob2; }
            set { _childdob2 = value; }
        }

        //Child 3
        string _childname3;
        public string ChildName3
        {
            get { return _childname3; }
            set { _childname3 = value; }
        }

        string _childnric3;
        public string ChildNRICNo3
        {
            get { return _childnric3; }
            set { _childnric3 = value; }
        }

        string _childdob3;
        public string ChildDOB3
        {
            get { return _childdob3; }
            set { _childdob3 = value; }
        }

        //Child 4
        string _childname4;
        public string ChildName4
        {
            get { return _childname4; }
            set { _childname4 = value; }
        }

        string _childnric4;
        public string ChildNRICNo4
        {
            get { return _childnric4; }
            set { _childnric4 = value; }
        }

        string _childdob4;
        public string ChildDOB4
        {
            get { return _childdob4; }
            set { _childdob4 = value; }
        }

        //Child 5
        string _childname5;
        public string ChildName5
        {
            get { return _childname5; }
            set { _childname5 = value; }
        }

        string _childnric5;
        public string ChildNRICNo5
        {
            get { return _childnric5; }
            set { _childnric5 = value; }
        }

        string _childdob5;
        public string ChildDOB5
        {
            get { return _childdob5; }
            set { _childdob5 = value; }
        }

        #endregion

        #region Tax Invoice Variables
        string _gstRegNumber;
        public string GSTRegNumber
        {
            get { return _gstRegNumber; }
            set { _gstRegNumber = value; }
        }

        string _transDate;
        public string TransactionDate
        {
            get { return _transDate; }
            set { _transDate = value; }
        }

        string _branchTerritory;
        public string BranchTerritory
        {
            get { return _branchTerritory; }
            set { _branchTerritory = value; }
        }

        string _accountAgency;
        public string AcountAgency
        {
            get { return _accountAgency; }
            set { _accountAgency = value; }
        }


        string _cardType;
        public string CardType
        {
            get { return _cardType; }
            set { _cardType = value; }
        }

        string _cardLastFourDigit;
        public string CardLastFourDigit
        {
            get { return _cardLastFourDigit; }
            set { _cardLastFourDigit = value; }
        }
        #endregion

        public EtiqaTAInsurancePDFOutput()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        public bool GenerateAllOuput(out string[] fileList)
        {
            fileList = new string[3];
            bool _retValue = false;
            try
            {
                fileList[0] = EtiqaTaxInvoiceOutputSample();
                fileList[1] = EtiqaCISample();
                fileList[2] = EtiqaPolicyWording();
                _retValue = true;
            }
            catch (Exception Ex)
            {
                _retValue = false;
            }

            return _retValue;
        }

        public string EtiqaCISample()
        {
            // Create a new PDF document
            PdfDocument document = new PdfDocument();
            document.Info.Title = _schedulewritingpagetitle;

            // Create an empty page
            PdfPage page = document.AddPage();

            // Get an XGraphics object for drawing
            XGraphics gfx = XGraphics.FromPdfPage(page);


            // Create a font
            XFont font = new XFont("Arial", 7, XFontStyle.Regular);
            XFont font1 = new XFont("Arial", 7.5, XFontStyle.Regular);
            XFont fontNormal = new XFont("Arial", 8, XFontStyle.Regular);
            XFont fontNormalB = new XFont("Arial", 7.5, XFontStyle.Bold);
            XFont fontNormalB2 = new XFont("Arial", 8, XFontStyle.Bold);
            XFont fontNormalB3 = new XFont("Arial", 9, XFontStyle.Bold);
            XFont fontBig = new XFont("Arial", 9, XFontStyle.Regular);
            XFont fontBigB = new XFont("Arial", 16, XFontStyle.Bold);
            XColor _xcolor = new XColor();
            _xcolor.R = 0;
            _xcolor.G = 0;
            _xcolor.B = 0;
            System.Drawing.Rectangle _rect = new System.Drawing.Rectangle(20, 10, 500, 100);
            XPen _pen = new XPen(_xcolor);
            _pen.Width = 1;

            XPen _pen2 = new XPen(XColors.Black, 0);

            int curX = 45;
            int curY = 35;

            gfx.DrawImage(XImage.FromFile(AppDomain.CurrentDomain.BaseDirectory + "images\\pdf\\header_etiqa-insurance.png"), new XRect(curX + 165, curY + 5, 150, 65));
            curY += 55;

            int _boxWidth = Convert.ToInt32(page.Width.Value) - 100;

            curY += 23;

            DrawBoxOnly(gfx, _xcolor, curX - 5 , curY, 530, 620, 1.35);
            gfx.DrawString("Vacation Shield Plus - Certificate of Insurance", fontBigB, XBrushes.Black, new XRect(curX + 92, curY + 5, 120, 20), XStringFormat.TopLeft);
            
            curY += 30;

            DrawBoxWithTextLeft(gfx, _xcolor, curX + 3, curY, 510, 15, 1.25, "IMPORTANT NOTICE","", "Arial", 8.0, XFontStyle.Bold, 2);
            curY += 15;
            DrawBoxWithTextLeft(gfx, _xcolor, curX + 3, curY, 510, 55, 1.25, "1.   STATEMENT pursuant to Section 25(5) of the Insurance Act - We would remind you that you must disclose fully and faithfully the facts", "", "Arial", 7.5, XFontStyle.Bold, 2);
            curY += 10;
            gfx.DrawString("you know or ought to know otherwise you may not receive any benefits from your Policy.", fontNormalB, XBrushes.Black, new XRect(curX + 20, curY + 5, 510, 13), XStringFormat.TopLeft);
            curY += 10;
            gfx.DrawString("2.  Please note that this insurance is subject to the premium being paid and received in full by the Company (a) before the inception date", fontNormalB, XBrushes.Black, new XRect(curX + 9, curY + 5, 510, 13), XStringFormat.TopLeft);
            curY += 10;
            gfx.DrawString("where the Policy is issued to an individual; or (b) within the period specified in the Premium Payment Warranty applied to the Policy in", fontNormalB, XBrushes.Black, new XRect(curX + 20, curY + 5, 510, 13), XStringFormat.TopLeft);
            curY += 10;
            gfx.DrawString("all other instances, failing which there will be no liability under this cover.", fontNormalB, XBrushes.Black, new XRect(curX + 20, curY + 5, 510, 13), XStringFormat.TopLeft);

            curY += 30;
            gfx.DrawString("A)   The Insured", fontNormalB2, XBrushes.Black, new XRect(curX + 9, curY + 5, 510, 13), XStringFormat.TopLeft);

            curY += 30;
            gfx.DrawString("Full Name (as in passport):", fontNormal, XBrushes.Black, new XRect(curX + 20, curY + 5, 510, 13), XStringFormat.TopLeft);
            gfx.DrawString(_customerName.ToUpper(), fontNormal, XBrushes.Black, new XRect(curX + 123, curY + 5, 390, 20), XStringFormat.TopLeft);
            gfx.DrawLine(_pen2, curX + 123, curY + 15, curX + 300, curY + 15);
            
            gfx.DrawString("(Male/Female) :", fontNormal, XBrushes.Black, new XRect(curX + 323, curY + 5, 510, 13), XStringFormat.TopLeft);
            gfx.DrawString(_gender, fontNormal, XBrushes.Black, new XRect(curX + 383, curY + 5, 190, 20), XStringFormat.TopLeft);
            gfx.DrawLine(_pen2, curX + 383, curY + 15, curX + 510, curY + 15);

            curY += 17;
            gfx.DrawString("Address:", fontNormal, XBrushes.Black, new XRect(curX + 20, curY + 5, 510, 13), XStringFormat.TopLeft);
            gfx.DrawString(_customerAddress1.ToUpper() + " " + _customerAddress2.ToUpper(), fontNormal, XBrushes.Black, new XRect(curX + 123, curY + 4, 390, 15), XStringFormat.TopLeft);
            gfx.DrawLine(_pen2, curX + 123, curY + 15, curX + 510, curY + 15);
            
            curY += 17;
            gfx.DrawString("Date of Birth:", fontNormal, XBrushes.Black, new XRect(curX + 20, curY + 5, 510, 13), XStringFormat.TopLeft);
            //gfx.DrawString((Convert.ToDateTime(_dob).ToString("dd-MMM-yyyy")).ToString(), fontNormal, XBrushes.Black, new XRect(curX + 123, curY + 5, 390, 20), XStringFormat.TopLeft);
            gfx.DrawString(_dob, fontNormal, XBrushes.Black, new XRect(curX + 123, curY + 5, 390, 20), XStringFormat.TopLeft);
            gfx.DrawLine(_pen2, curX + 123, curY + 15, curX + 250, curY + 15);

            gfx.DrawString("Passport or NRIC No :", fontNormal, XBrushes.Black, new XRect(curX + 270, curY + 5, 510, 13), XStringFormat.TopLeft);
            gfx.DrawString(_nric, fontNormal, XBrushes.Black, new XRect(curX + 360, curY + 5, 390, 20), XStringFormat.TopLeft);
            gfx.DrawLine(_pen2, curX + 360, curY + 15, curX + 510, curY + 15);

            curY += 20;
            gfx.DrawString("B)   Family Members Insured", fontNormalB2, XBrushes.Black, new XRect(curX + 9, curY + 5, 510, 13), XStringFormat.TopLeft);
            curY += 25;

            //draw table
            gfx.DrawLine(_pen2, curX + 9, curY, 550, curY);
            gfx.DrawLine(_pen2, curX + 9, curY, curX + 9, curY + 65);
            gfx.DrawLine(_pen2, curX + 30, curY, curX + 30, curY + 65);
            gfx.DrawLine(_pen2, curX + 221, curY, curX + 221, curY + 65);
            gfx.DrawLine(_pen2, curX + 321, curY, curX + 321, curY + 65);
            gfx.DrawLine(_pen2, curX + 401, curY, curX + 401, curY + 65);
            gfx.DrawLine(_pen2, curX + 505, curY, curX + 505, curY + 65);

            gfx.DrawString("S/No", fontNormal, XBrushes.Black, new XRect(curX + 11, curY + 5, 30, 15), XStringFormat.TopLeft);
            gfx.DrawString("Name", fontNormal, XBrushes.Black, new XRect(curX + 110, curY + 5, 221, 15), XStringFormat.TopLeft);
            gfx.DrawString("Relationship to Insured", fontNormal, XBrushes.Black, new XRect(curX + 230, curY + 5, 100, 15), XStringFormat.TopLeft);
            gfx.DrawString("Sex", fontNormal, XBrushes.Black, new XRect(curX + 350, curY + 5, 80, 15), XStringFormat.TopLeft);
            gfx.DrawString("Date of Birth", fontNormal, XBrushes.Black, new XRect(curX + 430, curY + 5, 104, 15), XStringFormat.TopLeft);

            gfx.DrawString("1", fontNormal, XBrushes.Black, new XRect(curX + 15, curY + 15, 30, 15), XStringFormat.TopLeft);

            curY += 15;
            gfx.DrawLine(_pen2, curX + 9, curY, 550, curY);
            gfx.DrawString("2", fontNormal, XBrushes.Black, new XRect(curX + 15, curY + 10, 30, 15), XStringFormat.TopLeft);
            curY += 10;
            gfx.DrawLine(_pen2, curX + 9, curY, 550, curY);
            gfx.DrawString("3", fontNormal, XBrushes.Black, new XRect(curX + 15, curY + 10, 30, 15), XStringFormat.TopLeft);            
            curY += 10;
            gfx.DrawLine(_pen2, curX + 9, curY, 550, curY);
            gfx.DrawString("4", fontNormal, XBrushes.Black, new XRect(curX + 15, curY + 10, 30, 15), XStringFormat.TopLeft);
            curY += 10;
            gfx.DrawLine(_pen2, curX + 9, curY, 550, curY);
            gfx.DrawString("5", fontNormal, XBrushes.Black, new XRect(curX + 15, curY + 10, 30, 15), XStringFormat.TopLeft);
            curY += 10;
            gfx.DrawLine(_pen2, curX + 9, curY, 550, curY);
            curY += 10;
            gfx.DrawLine(_pen2, curX + 9, curY, 550, curY);
            curY += 5;

            gfx.DrawString("(Children under any Family Plan must be under the age of 18 or up to 24 years if still studying full-time in a recognized institution of higher learning)", font, XBrushes.Black, new XRect(curX + 7, curY, 30, 15), XStringFormat.TopLeft);
            curY += 15;
            gfx.DrawString("C)   Coverage", fontNormalB2, XBrushes.Black, new XRect(curX + 9, curY + 5, 510, 13), XStringFormat.TopLeft);
            gfx.DrawLine(_pen2, curX + 360, curY + 5, curX + 510, curY + 5);
            gfx.DrawLine(_pen2, curX + 360, curY + 5, curX + 360, curY + 59);
            gfx.DrawLine(_pen2, curX + 510, curY + 5, curX + 510, curY + 59);
            gfx.DrawString("For Drive to Malaysia", fontNormalB2, XBrushes.Black, new XRect(curX + 390, curY + 10, 100, 13), XStringFormat.TopLeft);
            gfx.DrawLine(_pen2, curX + 390, curY + 19, curX + 470, curY + 19);
            curY += 20;

            gfx.DrawString("Type of Plan:", fontNormal, XBrushes.Black, new XRect(curX + 20, curY + 5, 510, 13), XStringFormat.TopLeft);
            gfx.DrawString(_typeofplan, fontNormal, XBrushes.Black, new XRect(curX + 125, curY + 5, 390, 20), XStringFormat.TopLeft);
            gfx.DrawLine(_pen2, curX + 123, curY + 15, curX + 320, curY + 15);

            curY += 17;
            gfx.DrawString("Type of Benefit:", fontNormal, XBrushes.Black, new XRect(curX + 20, curY + 5, 510, 13), XStringFormat.TopLeft);
            gfx.DrawString(_planname + " " , fontNormal, XBrushes.Black, new XRect(curX + 125, curY + 4, 390, 15), XStringFormat.TopLeft);
            gfx.DrawLine(_pen2, curX + 123, curY + 15, curX + 320, curY + 15);
            gfx.DrawString("Vehicle Registration No:__________", fontNormalB2, XBrushes.Black, new XRect(curX + 365, curY - 5, 110, 13), XStringFormat.TopLeft);

            curY += 17;
            gfx.DrawString("Period of Cover: From", fontNormal, XBrushes.Black, new XRect(curX + 20, curY + 5, 120, 13), XStringFormat.TopLeft);
            gfx.DrawString(_startPeriod, fontNormal, XBrushes.Black, new XRect(curX + 140, curY + 5, 120, 20), XStringFormat.TopLeft);
            gfx.DrawLine(_pen2, curX + 123, curY + 15, curX + 200, curY + 15);
            gfx.DrawLine(_pen2, curX + 360, curY + 5, curX + 510, curY + 5);

            gfx.DrawString(" to ", fontNormal, XBrushes.Black, new XRect(curX + 220, curY + 5, curX + 220, 13), XStringFormat.TopLeft);
            gfx.DrawString(_endPeriod, fontNormal, XBrushes.Black, new XRect(curX + 267, curY + 5, 120, 20), XStringFormat.TopLeft);
            gfx.DrawLine(_pen2, curX + 250, curY + 15, curX + 320, curY + 15);

            gfx.DrawString(_noofdays + " (days)", fontNormal, XBrushes.Black, new XRect(curX + 325, curY + 5, curX + 220, 13), XStringFormat.TopLeft);

            curY += 17;
            gfx.DrawString("Destination:", fontNormal, XBrushes.Black, new XRect(curX + 20, curY + 5, 510, 13), XStringFormat.TopLeft);
            gfx.DrawString(_destination + " ", fontNormal, XBrushes.Black, new XRect(curX + 125, curY + 4, 390, 15), XStringFormat.TopLeft);
            gfx.DrawLine(_pen2, curX + 123, curY + 15, curX + 320, curY + 15);

            curY += 17;
            gfx.DrawString("Premium:", fontNormal, XBrushes.Black, new XRect(curX + 20, curY + 5, 120, 13), XStringFormat.TopLeft);
            gfx.DrawString("S$", fontNormal, XBrushes.Black, new XRect(curX + 100, curY + 5, 20, 13), XStringFormat.TopLeft);
            gfx.DrawString(_newpremium, fontNormal, XBrushes.Black, new XRect(curX + 140, curY + 5, 120, 20), XStringFormat.TopLeft);
            gfx.DrawLine(_pen2, curX + 123, curY + 15, curX + 200, curY + 15);
            gfx.DrawString("(no GST is required)", fontNormal, XBrushes.Black, new XRect(curX + 200, curY + 5, curX + 200, 13), XStringFormat.TopLeft);

            curY += 40;
            gfx.DrawLine(_pen2, curX + 9, curY, 550, curY);
            gfx.DrawLine(_pen2, curX + 9, curY + 10, curX + 140, curY + 10);
            gfx.DrawLine(_pen2, curX + 9, curY, curX + 9, curY + 32);
            gfx.DrawLine(_pen2, curX + 140, curY, curX + 140, curY + 32);
            gfx.DrawLine(_pen2, curX + 270, curY, curX + 270, curY + 32);
            gfx.DrawLine(_pen2, curX + 505, curY, curX + 505, curY + 32);

            gfx.DrawString("Certificate No.", fontNormal, XBrushes.Black, new XRect(curX + 10, curY, 140, 13), XStringFormat.TopLeft);
            curY += 32;
            gfx.DrawLine(_pen2, curX + 9, curY, 550, curY);
            gfx.DrawString(_policyNumber, fontNormalB2, XBrushes.Black, new XRect(curX + 10, curY - 9, 170, 13), XStringFormat.TopLeft);
            gfx.DrawString("Date of Issue", fontNormal, XBrushes.Black, new XRect(curX + 141, curY - 9, 120, 13), XStringFormat.TopLeft);
            gfx.DrawString(Convert.ToDateTime(_transDate).ToString("dd-MMM-yyyy"), fontNormalB2, XBrushes.Black, new XRect(curX + 200, curY - 9, 100, 13), XStringFormat.TopLeft);
            gfx.DrawString("Authorised Signatory", fontNormal, XBrushes.Black, new XRect(curX + 271, curY - 9, 120, 13), XStringFormat.TopLeft);
            gfx.DrawImage(XImage.FromFile(AppDomain.CurrentDomain.BaseDirectory + "images\\pdf\\etiqa_signature.jpg"), curX + 370, curY - 30, 68, 28);

            curY += 15;

            gfx.DrawLine(_pen2, curX + 9, curY, 550, curY);
            gfx.DrawLine(_pen2, curX + 9, curY, curX + 9, curY + 48);
            gfx.DrawLine(_pen2, curX + 505, curY, curX + 505, curY + 48);

            gfx.DrawString("POLICY OWNERS' PROTECTION SCHEME", fontNormalB2, XBrushes.Black, new XRect(curX + 180, curY, 140, 13), XStringFormat.TopLeft);
            gfx.DrawString("This policy is protected under the Policy Owner's Protection Scheme which is administered by the Singapore Deposit Insurance Corporation (SDIC).", font1, XBrushes.Black, new XRect(curX + 11, curY + 10, 550, 13), XStringFormat.TopLeft);
            gfx.DrawString("Coverage for your policy is automatic and no further action is required from you. For more information on the types of benefits that are covered under", font1, XBrushes.Black, new XRect(curX + 11, curY + 20, 550, 13), XStringFormat.TopLeft);
            gfx.DrawString("the scheme as well as the limits of coverage, where application, please contact your insurer or visit the GIA/LIA or SDIC website (www.gia.org.sg or", font1, XBrushes.Black, new XRect(curX + 11, curY + 30, 550, 13), XStringFormat.TopLeft);
            gfx.DrawString("www.lia.org.sg www.sdic.org.sg", font1, XBrushes.Black, new XRect(curX + 200, curY + 40, 140, 13), XStringFormat.TopLeft);

            curY += 48;
            gfx.DrawLine(_pen2, curX + 9, curY, 550, curY);
            curY += 15;
            gfx.DrawString("Underwritten By:", fontNormal, XBrushes.Black, new XRect(curX + 10, curY, 140, 13), XStringFormat.TopLeft);
            curY += 10;
            gfx.DrawString("Etiqa Insurance Pte Ltd", fontNormalB2, XBrushes.Black, new XRect(curX + 10, curY, 140, 13), XStringFormat.TopLeft);
            curY += 15;
            gfx.DrawImage(XImage.FromFile(AppDomain.CurrentDomain.BaseDirectory + "images\\pdf\\header_etiqa-insurance.png"), new XRect(curX , curY - 5, 100, 30));

            gfx.DrawString("Emergency Services Hotline: (65) 6327-2215", fontNormalB3, XBrushes.Black, new XRect(curX + 270, curY - 5, 140, 13), XStringFormat.TopLeft);
            gfx.DrawString("MONDIAL ASSISTANCE", fontNormalB3, XBrushes.Black, new XRect(curX + 310, curY + 5, 140, 13), XStringFormat.TopLeft);

            curY += 38;

            gfx.DrawString("This Certificate is issued in accordance and should be read in conjunction with the terms, conditions and exceptions of Vacation Shield Plus Insurance Policy", font1, XBrushes.Black, new XRect(curX - 1, curY, 140, 13), XStringFormat.TopLeft);

            //if (isPromo)
            //{
            //    DrawBoxWithText(gfx, _xcolor, curX + 3, curY, 515, 175, 2.0d, "", "Verdana", 6.0, XFontStyle.Bold);
            //}
            //else
            //{
            //    DrawBoxWithText(gfx, _xcolor, curX + 3, curY, 515, 160, 2.0d, "", "Verdana", 6.0, XFontStyle.Bold);
            //}

            //DrawBoxWithText(gfx, _xcolor, curX + 3, curY, 120, 20, 1.25, "", "Verdana", 6.0, XFontStyle.Bold);
            //DrawBoxWithText(gfx, _xcolor, curX + 123, curY, 250, 20, 1.25, "", "Verdana", 6.0, XFontStyle.Bold);
            //DrawBoxWithText(gfx, _xcolor, curX + 373, curY, 145, 20, 1.25, "", "Verdana", 6.0, XFontStyle.Bold);

            //gfx.DrawString("Agency     ", fontNormalB, XBrushes.Black, new XRect(curX + 8, curY + 5, 120, 20), XStringFormat.TopLeft);
            ////gfx.DrawString("    000598", fontNormal, XBrushes.Black, new XRect(curX + 78, curY + 5, 120, 20), XStringFormat.TopLeft);
            //gfx.DrawString("    " + _agency, fontNormal, XBrushes.Black, new XRect(curX + 78, curY + 5, 120, 20), XStringFormat.TopLeft);
            //gfx.DrawString("Class of Policy", fontNormalB, XBrushes.Black, new XRect(curX + 128, curY + 5, 250, 20), XStringFormat.TopLeft);
            //gfx.DrawString(_classOfPolicy, fontNormal, XBrushes.Black, new XRect(curX + 223, curY + 5, 250, 20), XStringFormat.TopLeft);
            //gfx.DrawString("Acceptance Date", fontNormalB, XBrushes.Black, new XRect(curX + 378, curY + 5, 250, 20), XStringFormat.TopLeft);
            //gfx.DrawString(_acceptanceDate, fontNormal, XBrushes.Black, new XRect(curX + 448, curY + 5, 100, 20), XStringFormat.TopLeft);

            //curY += 20;
            //DrawBoxWithText(gfx, _xcolor, curX + 3, curY, 120, 20, 1.25, "", "Verdana", 6.0, XFontStyle.Bold);
            //DrawBoxWithText(gfx, _xcolor, curX + 123, curY, 395, 20, 1.25, "", "Verdana", 6.0, XFontStyle.Bold);

            //gfx.DrawString("Account     ", fontNormalB, XBrushes.Black, new XRect(curX + 8, curY + 5, 120, 20), XStringFormat.TopLeft);
            //gfx.DrawString("    " + _account, fontNormal, XBrushes.Black, new XRect(curX + 78, curY + 5, 120, 20), XStringFormat.TopLeft);
            //gfx.DrawString("Period of Insurance", fontNormalB, XBrushes.Black, new XRect(curX + 128, curY + 5, 390, 20), XStringFormat.TopLeft);
            //gfx.DrawString("From " + _startPeriod + " to " + _endPeriod + "  (both dates inclusive)", fontNormal, XBrushes.Black, new XRect(curX + 223, curY + 5, 390, 20), XStringFormat.TopLeft);

            //curY += 20;
            //DrawBoxWithText(gfx, _xcolor, curX + 3, curY, 120, 50, 1.25, "", "Verdana", 6.0, XFontStyle.Bold);
            //DrawBoxWithText(gfx, _xcolor, curX + 123, curY, 395, 20, 1.25, "", "Verdana", 6.0, XFontStyle.Bold);
            //DrawBoxWithText(gfx, _xcolor, curX + 123, curY + 20, 395, 30, 1.25, "", "Verdana", 6.0, XFontStyle.Bold);

            //gfx.DrawString("Client", fontNormalB, XBrushes.Black, new XRect(curX + 8, curY + 5, 120, 20), XStringFormat.TopLeft);
            //gfx.DrawString("Insured Name", fontNormalB, XBrushes.Black, new XRect(curX + 128, curY + 5, 390, 20), XStringFormat.TopLeft);
            //gfx.DrawString(_customerName.ToUpper(), fontNormal, XBrushes.Black, new XRect(curX + 223, curY + 5, 390, 20), XStringFormat.TopLeft);

            //curY += 20;
            //gfx.DrawString("Insured Address", fontNormalB, XBrushes.Black, new XRect(curX + 128, curY + 5, 390, 20), XStringFormat.TopLeft);
            //gfx.DrawString(_customerAddress1.ToUpper(), fontNormal, XBrushes.Black, new XRect(curX + 223, curY + 4, 390, 15), XStringFormat.TopLeft);
            //gfx.DrawString(_customerAddress2.ToUpper(), fontNormal, XBrushes.Black, new XRect(curX + 223, curY + 17, 390, 15), XStringFormat.TopLeft);

            //curY += 30;
            //double Premium = (Convert.ToDouble(_totalDueInvoice) / 107 * 100);
            //gfx.DrawString("Annual Premium", fontNormalB, XBrushes.Black, new XRect(curX + 8, curY + 5, 120, 18), XStringFormat.TopLeft);
            //gfx.DrawString("S$", fontNormal, XBrushes.Black, new XRect(curX + 350, curY + 5, 120, 18), XStringFormat.TopLeft);
            //gfx.DrawString(String.Format("{0:0,0.00}", Premium), fontNormal, XBrushes.Black, new XRect(curX + 480, curY + 5, 120, 18), XStringFormat.TopLeft);

            //curY += 18;
            //DrawBoxWithText(gfx, _xcolor, curX + 5, curY, 510, 0, .75, "", "Verdana", 6.0, XFontStyle.Bold);
            //gfx.DrawString("Subtotal:", fontNormalB, XBrushes.Black, new XRect(curX + 300, curY + 3, 120, 16), XStringFormat.TopLeft);
            //gfx.DrawString("S$", fontNormalB, XBrushes.Black, new XRect(curX + 350, curY + 3, 120, 16), XStringFormat.TopLeft);
            //gfx.DrawString(String.Format("{0:0,0.00}", Premium), fontNormalB, XBrushes.Black, new XRect(curX + 480, curY + 3, 120, 16), XStringFormat.TopLeft);

            //curY += 16;
            //double GSTAmount = (Convert.ToDouble(_totalDueInvoice) / 107 * 7);
            //DrawBoxWithText(gfx, _xcolor, curX + 5, curY + 10, 510, 0, .75, "", "Verdana", 6.0, XFontStyle.Bold);
            //gfx.DrawString("Add GST (7.00%):", fontNormalB, XBrushes.Black, new XRect(curX + 275, curY, 120, 16), XStringFormat.TopLeft);
            //gfx.DrawString("S$", fontNormalB, XBrushes.Black, new XRect(curX + 350, curY, 120, 16), XStringFormat.TopLeft);
            //gfx.DrawString(String.Format("{0:0,0.00}", GSTAmount), fontNormal, XBrushes.Black, new XRect(curX + 480, curY, 120, 16), XStringFormat.TopLeft);

            //if (isPromo)
            //{
            //    double discountprice = (Convert.ToSingle(_totalDueInvoice) * .10);
            //    curY += 16;
            //    DrawBoxWithText(gfx, _xcolor, curX + 5, curY + 12, 510, 1, .75, "", "Verdana", 6.0, XFontStyle.Bold);
            //    gfx.DrawString("Promo Discount (10%):", fontNormalB, XBrushes.Black, new XRect(curX + 255, curY, 120, 16), XStringFormat.TopLeft);
            //    gfx.DrawString("S$", fontNormalB, XBrushes.Black, new XRect(curX + 350, curY, 120, 16), XStringFormat.TopLeft);
            //    gfx.DrawString("[" + String.Format("{0:0,0.00}" + "]", discountprice), fontNormal, XBrushes.Black, new XRect(curX + 480, curY, 120, 16), XStringFormat.TopLeft);

            //    curY += 18;
            //    DrawBoxWithText(gfx, _xcolor, curX + 5, curY + 12, 510, 1, .75, "", "Verdana", 6.0, XFontStyle.Bold);
            //    gfx.DrawString("Total Due:", fontNormalB, XBrushes.Black, new XRect(curX + 295, curY, 120, 18), XStringFormat.TopLeft);
            //    gfx.DrawString("S$", fontNormalB, XBrushes.Black, new XRect(curX + 350, curY, 120, 18), XStringFormat.TopLeft);
            //    gfx.DrawString(_newpremium, fontNormalB, XBrushes.Black, new XRect(curX + 480, curY, 120, 18), XStringFormat.TopLeft);
            //}
            //else
            //{
            //    curY += 18;
            //    DrawBoxWithText(gfx, _xcolor, curX + 5, curY + 12, 510, 1, .75, "", "Verdana", 6.0, XFontStyle.Bold);
            //    gfx.DrawString("Total Due:", fontNormalB, XBrushes.Black, new XRect(curX + 295, curY, 120, 18), XStringFormat.TopLeft);
            //    gfx.DrawString("S$", fontNormalB, XBrushes.Black, new XRect(curX + 350, curY, 120, 18), XStringFormat.TopLeft);
            //    gfx.DrawString(_totalDueInvoice, fontNormalB, XBrushes.Black, new XRect(curX + 480, curY, 120, 18), XStringFormat.TopLeft);
            //}

            string _filePath = GetFilePath();
            string filename = _filePath + "Etiqa_TI_CI_" + _proposalId + ".pdf";

            System.IO.MemoryStream stream = new System.IO.MemoryStream();
            document.Save(filename);
            stream.Close();
            document.Close();
            return filename;
        }

        public string EtiqaTaxInvoiceOutputSample()
        {

            // Create a new PDF document
            PdfDocument document = new PdfDocument();
            document.Info.Title = _taxinvoicepagetitle;

            // Create an empty page
            PdfPage page = document.AddPage();

            // Get an XGraphics object for drawing
            XGraphics gfx = XGraphics.FromPdfPage(page);

            // Create a font
            XFont font = new XFont("Verdana", 9, XFontStyle.Bold);

            XColor _xcolor = new XColor();
            _xcolor.R = 0;
            _xcolor.G = 0;
            _xcolor.B = 0;
            System.Drawing.Rectangle _rect = new System.Drawing.Rectangle(20, 10, 500, 100);
            XPen _pen = new XPen(_xcolor);

            int curX = 45;
            int curY = 50;


            gfx.DrawImage(XImage.FromFile(AppDomain.CurrentDomain.BaseDirectory + "images\\pdf\\header_etiqa_tax.png"), new XRect(curX, curY, 520, 111));
            curY += 85;

            int _boxWidth = Convert.ToInt32(page.Width.Value) - 100;

            //DrawBoxWithText(gfx, _xcolor, curX, curY, _boxWidth, 19, 0.8d, "", "Verdana", 6.0, XFontStyle.Regular, XBrushes.Yellow);
            //DrawBoxWithText(gfx, _xcolor, curX, curY, _boxWidth, 20, 1.0d, "TAX INVOICE", "Verdana", 9.0d, XFontStyle.Bold);
            curY += 25;

            _xcolor.R = 255;
            _xcolor.G = 255;
            _xcolor.B = 255;

            DrawBoxWithText(gfx, _xcolor, curX, curY, _boxWidth, 20, 0, "Debit Note", "Verdana", 9.0d, XFontStyle.Bold);
            curY += 20;

            XFont _textFontB = new XFont("Verdana", 8, XFontStyle.Bold);
            XFont _textFontR = new XFont("Verdana", 8, XFontStyle.Regular);
            gfx.DrawString("GST Reg. No. " + _gstRegNumber, _textFontB, XBrushes.Black, new XRect(curX, curY, 50, 15), XStringFormat.TopLeft);
            gfx.DrawString("Transaction/Due Date : " + (Convert.ToDateTime(_transDate)).ToString("dd/MM/yyyy"), _textFontB, XBrushes.Black, new XRect(curX + 330, curY, 50, 15), XStringFormat.TopLeft);
            curY += 40;

            gfx.DrawString(_customerName.ToUpper(), _textFontB, XBrushes.Black, new XRect(curX + 30, curY, 50, 15), XStringFormat.TopLeft);
            curY += 10;

            string _tmpAddress1 = "";
            string[] _addresslist = _customerAddress1.Split(',');
            for (int _d = 0; _d < _addresslist.Length - 1; _d++)
            {
                if (_d == 0 || _d == 1)
                {
                    _tmpAddress1 += _addresslist[_d] + ", ";
                    //curY += 10;
                }
                else if (_d == 2)
                {
                    _customerAddress2 = _addresslist[_d].Trim() + ", " + _customerAddress2;
                }
                else
                {
                    break;
                }
            }
            _customerAddress1 = _tmpAddress1;

            gfx.DrawString(_customerAddress1.ToUpper(), _textFontR, XBrushes.Black, new XRect(curX + 30, curY, 50, 15), XStringFormat.TopLeft);
            curY += 10;
            gfx.DrawString(_customerAddress2.ToUpper(), _textFontR, XBrushes.Black, new XRect(curX + 30, curY, 50, 15), XStringFormat.TopLeft);
            curY += 30;

            string[,] _arrNewData = new string[,]{{"Type Of Policy", _classOfPolicy},
                          {"Certificate Number", _policyNumber},
                          {"Period of Cover", "From " + _startPeriod + " to " + _endPeriod + "(both dates inclusive)"},
                          {"Main Insured's Name", _customerName},
                          {"Insured's Address", _customerAddress1},
                          {"", _customerAddress2},
                          {"Branch / Territory",_branchTerritory},
                          {"Account / Agency",_accountAgency}};

            int[] _colArrWidth = { 140, 300 };

            _xcolor.R = 0;
            _xcolor.G = 0;
            _xcolor.B = 0;

            DrawBoxWithTextList(gfx, _xcolor, curX, curY, _boxWidth, 12, 8, 2, 1.5d, "Verdana", 8.7, XFontStyle.Regular, _arrNewData, _colArrWidth);

            curY += 180;
            if (isPromo)
            {
                double discountprice = (Convert.ToSingle(_totalDueInvoice) * .10);
                string[,] _arrPremiumData = new string[,]{{"Annual Premium (no GST is required)", "           S$        "+_totalDueInvoice},
                          {"10% Festive Promo Discount ", "           S$        "+String.Format("{0:0,0.00}", discountprice) + ""},{"", "_________________________"},
                          {"Total Due", "           S$        "+_newpremium},
                          };

                _xcolor.R = 0;
                _xcolor.G = 0;
                _xcolor.B = 0;
                int[] _colPremiumArrWidth = { 300, 150 };
                DrawBoxWithTextList(gfx, _xcolor, curX, curY, _boxWidth, 10, 4, 2, 2.0d, "Verdana", 9, XFontStyle.Regular, _arrPremiumData, _colPremiumArrWidth);

            }
            else
            {
                string[,] _arrPremiumData = new string[,]{{"Annual Premium (no GST is required)", "           S$        "+_totalDueInvoice},{"", "_________________________"},
                          {"Total Due", "           S$        "+_totalDueInvoice},
                          };

                _xcolor.R = 0;
                _xcolor.G = 0;
                _xcolor.B = 0;
                int[] _colPremiumArrWidth = { 300, 150 };
                DrawBoxWithTextList(gfx, _xcolor, curX, curY, _boxWidth, 10, 3, 2, 2.0d, "Verdana", 9, XFontStyle.Regular, _arrPremiumData, _colPremiumArrWidth);

            }

            curY += 90;
            gfx.DrawString("Paid via " + _cardType + " XXXX XXXX XXXX XXXX" + _cardLastFourDigit, _textFontB, XBrushes.Black, new XRect(curX, curY, 50, 15), XStringFormat.TopLeft);
            curY += 10;
            gfx.DrawString("Signed for and on behalf of the company", _textFontR, XBrushes.Black, new XRect(curX, curY, 50, 15), XStringFormat.TopLeft);
            curY += 10;
            gfx.DrawImage(XImage.FromFile(AppDomain.CurrentDomain.BaseDirectory + "images\\pdf\\etiqa_signature.jpg"), curX + 50, curY, 80, 40);
            curY += 35;
            gfx.DrawString("_______________________________", _textFontB, XBrushes.Black, new XRect(curX, curY, 50, 15), XStringFormat.TopLeft);
            curY += 10;
            gfx.DrawString("Authorized Signature", _textFontR, XBrushes.Black, new XRect(curX, curY, 50, 15), XStringFormat.TopLeft);

            string _filePath = GetFilePath();
            string filename = _filePath + "Etiqa_TI_TaxInvoice_" + _proposalId + ".pdf";
            System.IO.MemoryStream stream = new System.IO.MemoryStream();
            document.Save(filename);
            stream.Close();
            document.Close();

            return filename;
        }

        public string EtiqaPolicyWording()
        {
            //string _currentDomainUrl = "http://" + HttpContext.Current.Request.Url.Host.ToString();
            string _filePath = CE.Configuration.MyConfigurationManager.GetAppSettingValue("FileOutputPath").ToString();
            //string filename = _filePath + "policy_docs\\etiqa\\VacationShieldPlusInsuranceWording - Finalized - 29Dec2011.pdf";
            string filename = _filePath + "policy_docs\\etiqa\\VacationShieldPlusInsuranceWording.pdf";
            return filename;
        }

        private void DrawBoxOnly(XGraphics _objG, XColor _xcolor, int x, int y, int width, int height, double borderWidth)
        {

            System.Drawing.Rectangle _rect = new System.Drawing.Rectangle(0, 0, 0, 0);
            _rect.X = x;
            _rect.Y = y;
            _rect.Width = width;
            _rect.Height = height;
            XPen _pen = new XPen(_xcolor);
            _pen.Width = borderWidth;
            _objG.DrawRectangle(_pen, _rect);
        }

        private void DrawBoxWithText(XGraphics _objG, XColor _xcolor, int x, int y, int width, int height, double borderWidth, string strText, string strFontName, double fontSize, XFontStyle xFontStyle)
        {

            System.Drawing.Rectangle _rect = new System.Drawing.Rectangle(0, 0, 0, 0);
            _rect.X = x;
            _rect.Y = y;
            _rect.Width = width;
            _rect.Height = height;
            XPen _pen = new XPen(_xcolor);
            _pen.Width = borderWidth;
            XFont font = new XFont(strFontName, fontSize, xFontStyle);
            _objG.DrawRectangle(_pen, _rect);
            _objG.DrawString(strText, font, XBrushes.Black, _rect, XStringFormats.Center);
        }

        private void DrawBoxWithText(XGraphics _objG, XColor _xcolor, int x, int y, int width, int height, double borderWidth, string strText, string strFontName, double fontSize, XFontStyle xFontStyle, XSolidBrush xSolidBrush)
        {

            System.Drawing.Rectangle _rect = new System.Drawing.Rectangle(0, 0, 0, 0);
            _rect.X = x + 1;
            _rect.Y = y + 1;
            _rect.Width = width - 2;
            _rect.Height = height - 1;


            XPen _pen = new XPen(_xcolor);
            _pen.Width = borderWidth;
            XFont font = new XFont(strFontName, fontSize, xFontStyle);
            //_objG.DrawRectangle(_pen, _rect);
            _objG.DrawRectangle(xSolidBrush, _rect);
            _objG.DrawString(strText, font, XBrushes.Black, _rect, XStringFormats.Center);

        }

        private void DrawBoxWithTextLeft(XGraphics _objG, XColor _xcolor, int x, int y, int width, int height, double borderWidth, string strText, string strText2, string strFontName, double fontSize, XFontStyle xFontStyle, int textalignment)
        {

            System.Drawing.Rectangle _rect = new System.Drawing.Rectangle(0, 0, 0, 0);
            _rect.X = x;
            _rect.Y = y;
            _rect.Width = width;
            _rect.Height = height;
            XPen _pen = new XPen(_xcolor);
            _pen.Width = borderWidth;
            XFont font = new XFont(strFontName, fontSize, xFontStyle);
            XFont font2 = new XFont(strFontName, fontSize, XFontStyle.Regular);
            _objG.DrawRectangle(_pen, _rect);
            _objG.DrawString(strText, font, XBrushes.Black, new XRect(x + 5, y + 5, width, height), XStringFormats.TopLeft);
            _objG.DrawString(strText2, font2, XBrushes.Black, new XRect(x + textalignment, y + 5, width, height), XStringFormats.TopLeft);

        }

        private void DrawBoxWithTextList(XGraphics _objG, XColor _xcolor, int x, int y, int width, int height, int rows, int cols, double borderWidth, string strFontName, double fontSize, XFontStyle xFontStyle, string[,] _arrData, int[] _arrColsWidth)
        {

            System.Drawing.Rectangle _rect = new System.Drawing.Rectangle(0, 0, 0, 0);
            _rect.X = x;
            _rect.Y = y;
            _rect.Width = width;
            _rect.Height = (height + 8) * rows;

            XColor _xOuterBoxColor = new XColor();
            _xOuterBoxColor.R = 0;
            _xOuterBoxColor.G = 0;
            _xOuterBoxColor.B = 0;

            XPen _pen = new XPen(_xcolor);
            _pen.Width = borderWidth;
            XFont font = new XFont(strFontName, fontSize, xFontStyle);
            XFont boldFont = new XFont(strFontName, fontSize, XFontStyle.Bold);
            _objG.DrawRectangle(_pen, _rect);

            System.Drawing.Rectangle _rectText = new System.Drawing.Rectangle(0, 0, 0, 0);
            _rectText.X = x + 5;
            _rectText.Y = y + 5;
            _rectText.Width = width;
            _rectText.Height = height;

            for (int i = 0; i < rows; i++)
            {
                // Draw the text
                for (int j = 0; j < cols; j++)
                {
                    _rectText.Width = _arrColsWidth[j];
                    if (j == 0)
                    {
                        _objG.DrawString(_arrData[i, j].ToString(), boldFont, XBrushes.Black, _rectText, XStringFormats.TopLeft);
                    }
                    else
                    {
                        _objG.DrawString(_arrData[i, j].ToString(), font, XBrushes.Black, _rectText, XStringFormats.TopLeft);
                    }
                    _rectText.X += _arrColsWidth[j];
                }
                _rectText.X = x + 5;
                _rectText.Y += height + 5;
            }

        }

        private void DrawTable(XGraphics _objG, int x, int y, int rows, int cols, int rowHeight, int[] _arrColsWidth, string[] _arrHeader, string[,] _arrData)
        {
            XColor _xcolor = new XColor();
            _xcolor.R = 0;
            _xcolor.G = 0;
            _xcolor.B = 0;
            System.Drawing.Rectangle _rect = new System.Drawing.Rectangle(0, 0, 0, 0);
            _rect.X = x;
            _rect.Y = y;
            _rect.Width = _arrColsWidth[0];
            _rect.Height = rowHeight;
            XPen _pen = new XPen(_xcolor);
            _pen.Width = 0.5d;
            XFont font = new XFont("Verdana", 5, XFontStyle.Regular);

            for (int h = 0; h < cols; h++)
            {
                _rect.Width = _arrColsWidth[h];
                _objG.DrawRectangle(_pen, _rect);
                _objG.DrawString(_arrHeader[h].ToString(), font, XBrushes.Black,
          new XRect(_rect.X + 3, _rect.Y + 3, 10, 10),
          XStringFormats.TopLeft);
                _rect.X += _arrColsWidth[h];
            }

            _rect.Y += rowHeight;
            _rect.X = x;

            for (int i = 0; i < rows; i++)
            {
                // Draw the text
                for (int j = 0; j < cols; j++)
                {
                    _rect.Width = _arrColsWidth[j];

                    _objG.DrawRectangle(_pen, _rect);
                    _objG.DrawString(_arrData[i, j].ToString(), font, XBrushes.Black,
              new XRect(_rect.X + 3, _rect.Y + 3, 10, 10),
              XStringFormats.TopLeft);
                    _rect.X += _arrColsWidth[j];
                }
                _rect.Y += rowHeight;
                _rect.X = x;
            }
        }

        public void ClearFields()
        {
            _proposalId = "";
            _schedulewritingpagetitle = "Etiqa - Schedule Writing";// "Etiqa - Schedule Writing
            _certificatepagetitle = "Etiqa - Certificate Of Insurance";// "Etiqa - Certificate Of Insurance
            _taxinvoicepagetitle = "Etiqa - Tax";// "Etiqa - Tax

            #region Customer Profile
            _customerName = "";// "BRYAN YU CHEE SIANG
            _customerAddress1 = "";// "123, JALAN 222
            _customerAddress2 = "";// "SINGAPORE 604565
            #endregion

            #region Schedule Writing Variables
            _agency = "";// "001045
            _classOfPolicy = "";// "MOTOR PRIVATE CAR
            _policyNumber = "";// "DMAP105004354
            _account = "";// "001045
            _issuedOn = "";// CE.Global.General.GetUTCDateTime().Day.ToString("00") + "/" + CE.Global.General.GetUTCDateTime().Month.ToString("00") + "/" + CE.Global.General.GetUTCDateTime().Year.ToString("0000") + " in SINGAPORE
            _replacePolicyNumber = "";// "DMAP095006346
            _client = "";// "
            _acceptanceDate = "";// CE.Global.General.GetUTCDateTime().Day.ToString("00") + "/" + CE.Global.General.GetUTCDateTime().Month.ToString("00") + "/" + CE.Global.General.GetUTCDateTime().Year.ToString("0000")="";
            //_basicPremiumAmount = "";// "S$1,529.55
            //_lessNCDPercent = "";// "50.00%
            //_lessNCDAmount = "";// "S$764.78-
            //_ncdProtectionPremiumPercent = "";// "10%
            //_ncdProtectionPremiumAmount = "";// "S$76.48
            //_totalAnnualPermium = "";// "S$841.25
            //_premiumDue = "";// "S$841.25
            //_premiumGST = "";// "S$58.89
            //_totalDueInvoice = "";// "S$900.14
            //_totalDueSchedule = "";// "S$900.14
            _occupation = "";// "INDOOR - IT

            #endregion



            #region Tax Invoice Variables
            _gstRegNumber = "";// "M90363266Y

            _transDate = "";// CE.Global.General.GetUTCDateTime().ToShortDateString()="";

            _branchTerritory = "";// "SINGAPORE / Singapore
            _accountAgency = "";
            _cardType = "";

            _cardLastFourDigit = "";
            #endregion
        }

        private string GetFilePath()
        {
            string _filePath = CE.Configuration.MyConfigurationManager.GetAppSettingValue("FileOutputPath").ToString();
            _filePath += "pdfoutput\\etiqa\\";
            CE.InputOut.MyIO _myIO = new CE.InputOut.MyIO();
            string _todaydate = CE.Global.General.GetUTCDateTime().ToString("yyyyMMMdd");
            if (!_myIO.CheckDirectory(_filePath + _todaydate))
            {
                if (_myIO.CreateDirectory(_filePath, _todaydate))
                {
                    _filePath += _todaydate + "\\";
                }
            }
            else
            {
                _filePath += _todaydate + "\\";
            }

            return _filePath;
        }
    }
}